package com.qwz.example;

import com.qwz.example.customer.Customer;
import com.qwz.example.customer.EnterpriseCustomer;
import com.qwz.example.customer.PersonalCustomer;
import com.qwz.example.middle.ObjectStructure;
import com.qwz.example.visitor.PredilctionAnalyzeVisitor;
import com.qwz.example.visitor.ServiceRequestVisitor;
import com.qwz.example.visitor.Visitor;
import com.qwz.example.visitor.WorthAnalyzeVisitor;

/**
* @Description: 访问者模式客户端
* @Package com.qwz.example.Client
* @author Qiuwuzhi
* @date 2019/12/27 17:32
* @version V1.0
*/
public class Client {

    public static void main(String[] args) {
        //创建ObjectStructure
        ObjectStructure objectStructure = new ObjectStructure();

        //准备些测试数据，创建客户对象，并加入ObjectStructure
        Customer enterpriseCustomer = new EnterpriseCustomer();
        enterpriseCustomer.setName("abc集团");
        objectStructure.addElement(enterpriseCustomer);

        Customer personalCustomer = new PersonalCustomer();
        personalCustomer.setName("sz");
        objectStructure.addElement(personalCustomer);

        //客户提出服务请求，传入服务请求的visitor
        Visitor serviceRequestVisitor = new ServiceRequestVisitor();
        objectStructure.handleRequest(serviceRequestVisitor);

        //要对客户进行偏好分析，传入偏好分析的visitor
        Visitor predilctionAnalyzeVisitor = new PredilctionAnalyzeVisitor();
        objectStructure.handleRequest(predilctionAnalyzeVisitor);
        //要对客户进行价值分析，传入价值分析的visitor
        Visitor worthAnalyzeVisitor = new WorthAnalyzeVisitor();
        objectStructure.handleRequest(worthAnalyzeVisitor);

    }
}
